<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form action="" style="margin: 5px 0; height: 51px">
            <Input v-model="name"   placeholder="根据用户名查找"  style="width: 200px;margin-right: 3px;"></Input>
            <Input v-model="phone"  placeholder="根据手机号查找"  style="width: 200px"></Input>
            <Input v-model="num"  placeholder="请输入最低金额"  style="width: 200px"></Input>
            <DatePicker v-model="zcks" type="datetime" placeholder="请输入提现开始时间" style="width: 200px"></DatePicker>
            <DatePicker v-model="zcjs" type="datetime" placeholder="请输入提现结束时间" style="width: 200px"></DatePicker>
            <FormItem   style="width: 200px;float: left;margin-right: 3px;" >
                <Select  v-model="stats" placeholder="请选择状态"  style="margin-right: 3px;">
                    <Option value="3">全部</Option>
                    <Option value="1">转账中</Option>
                    <Option value="2">已退款</Option>
                    <Option value="-3">转账失败已退款</Option>
                    <Option value="-2">转账成功</Option>
                </Select>
            </FormItem>
            <span style="margin-left: 10px;line-height: 30px;">总额: {{sum}}</span>
            <Button type="info"  style="float: right;margin-right: 5px" @click="load">查询</Button>
        </Form>
        <Table style="float: left" :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;" show-total @on-page-size-change='pageSizes'  show-elevator show-sizer @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    export default {
        data() {
            return {
                loading: true,
                Message:[],
                admin:true,
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '流水号',
                        align: 'center',
                        key: 'id',
                        editable: true
                    },
                    {
                        title: '用户名',
                        align: 'center',
                        key: 'userName',
                        editable: true
                    },
                    {
                        title: '用户真实名',
                        align: 'center',
                        key: 'idName'
                    },
                    {
                        title: '手机号',
                        align: 'center',
                        key: 'userPhone',
                        editable: true
                    },
                    {
                        title: '顶级账户名称',
                        align: 'center',
                        key: 'areaName',
                        editable: true
                    },
                    {
                        title: '提现USDI数量',
                        align: 'center',
                        key: 'outUsernumber',
                        editable: true
                    },
                    {
                        title: '添加时间',
                        align: 'center',
                        width: 160,
                        render: (h, params) => {
                            return params.row.createTime.replace(/\T/g, ' ').substring(0,19)
                        }
                    },
                    {
                        title: '审核时间',
                        align: 'center',
                        width: 160,
                        render: (h, params) => {
                            if(params.row.checkTime) {
                                return params.row.checkTime.replace(/\T/g, ' ').substring(0, 19)
                            }else {
                                return ''
                            }
                        }
                    },
                    {
                        title: '审核状态',
                        align: 'center',
                        key: 'status',
                        render: (h, params) => {
                            if(params.row.status == '0'){
                                return '未审核'
                            }else if(params.row.status == '1'){
                                return '转账中'
                            }else if(params.row.status == '2'){
                                return '已退款'
                            }else if(params.row.status == '-3'){
                                return '转账失败已退款'
                            }else if(params.row.status == '-2'){
                                return '转账成功'
                            }
                        }
                    }
                ],
                name: '',
                phone: '',
                zcks:'',
                zcjs:'',
                num:'',
                stats:'',
                pageNum:0,
                initPage:1,
                sum:0,
                pageSize:10
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            handleDel (val, index) {
                this.$Message.success('删除了第' + (index + 1) + '行数据');
            },
            setTime(time){
                var date = new Date(time);
                var month = date.getMonth() + 1
                var day =  date.getDate()
                var hours =   date.getHours()
                var minutes = date.getMinutes()
                var datese = date.getSeconds()
                if(datese /1  < 10){
                    datese = '0' +  datese
                }
                if(month /1  < 10){
                    month = '0' +  month
                }
                if(day /1  < 10){
                    day = '0' +  day
                }
                if(hours /1  < 10){
                    hours = '0' +  hours
                }
                if(minutes /1  < 10){
                    minutes = '0' +  minutes
                }
                return date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
            },
            load (index){
                let _this = this
                let params = new URLSearchParams()
                _this.loading = true
                if(index == '1'){
                    _this.initPage = 1
                }
                params.append('page', _this.initPage)
                params.append('status', _this.stats)
                params.append('username', _this.name)
                params.append('phone', _this.phone)
                params.append('tradeNumber', _this.num)
                params.append('pageSize', _this.pageSize)
                params.append('area','')
                if(_this.zcks){
                    params.append('time', _this.setTime(_this.zcks))
                }else{
                    params.append('time','')
                }
                if(_this.zcjs){
                    params.append('endtime', _this.setTime(_this.zcjs))
                }else{
                    params.append('endtime','')
                }
                $http.post('/backgroundAuditor/findAllBy',params).then(function (res) {
                    if(res.suc){
                    _this.Message = res.result.rows
                    _this.loading = false
                    _this.pageNum = res.result.total
                }else{
                    if(res.msg == "请先登录"){
                        _this.$Message.error('请重新登录！');
                    }else{
                        _this.$Message.error(res.msg);
                    }
                }
                })
                let paramss = new URLSearchParams()
                paramss.append('username', _this.name)
                paramss.append('status','')
                paramss.append('phone', _this.phone)
                paramss.append('tradeNumber', _this.num)
                paramss.append('area','')
                if(_this.zcks){
                    paramss.append('time', _this.setTime(_this.zcks))
                }else{
                    paramss.append('time','')
                }
                if(_this.zcjs){
                    paramss.append('endtime', _this.setTime(_this.zcjs))
                }else{
                    paramss.append('endtime','')
                }
                $http.post('/backgroundAuditor/findAllByTotal',paramss).then(function (ress) {
                    _this.sum = ress.result
                })
            },
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            },
            pageSizes(val){
                this.pageSize = val
                this.loading = true
                this.load(1)
            }
        }
    }
</script>
<style>
</style>

